﻿namespace Golf.Core
{
    public abstract class BusinessObjectBase
    {
        public int Id { get; protected set; }

        public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;
            if (!obj.GetType().Equals(this.GetType()))
                return false;
            if (object.ReferenceEquals(this, obj))
                return true;
            BusinessObjectBase toCompare = obj as BusinessObjectBase;
            if (this.Id == 0 || toCompare.Id == 0)
                return false;
            else
                return this.Id == toCompare.Id;
        }

        public override string ToString()
        {
            return Id.ToString();
        }
    }
}